<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改员工</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
</head>
<body >
<div id="aaa">
    <form class="layui-form" action="" id="update_staff">
        <input type="hidden" class="input-text" id="id" name="id">
        <div class="layui-form-item layui-row layui-col-xs10" style="padding-top: 10px;">
            <label class="layui-form-label">离职时间</label>
            <div class="layui-input-block">
                <input type="text" name="rztime" id="start_time" lay-verify="required" autocomplete="off" placeholder="请输入离职时间" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-row layui-col-xs10 layui-col-xs-offset2" >
            <div class="">
                <button class="layui-btn" id="addWuye" lay-submit lay-filter="addWuye">离职</button>
                <button type="reset" id="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/js/layui/layui.js"></script>
<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>

<script>

    //url 传参
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var a = decodeURI(window.location.search);
        var r = a.substr(1).match(reg);//search,查询？后面的参数，并匹配正则
        if(r!=null)return  unescape(r[2]); return null;
    }

    window.onload = function(){
        var form = layui.form;
        $("input[name='id']").val(GetQueryString("id"));
    }

    layui.use(['form' , 'jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //离职操作
        form.on('submit(addWuye)',function(data){
            data.field.id = $("#id").val();
            data.field.lztime = $("#start_time").val();
            $.ajax({
                url:"/staff/stafflizhi?id="+ data.field.id+"&status=1"
                ,type:"get"
                ,success:function (data) {
                    if(data.code==0){
                        layer.close(layer.index);
                        layer.msg('操作成功');
                        setTimeout(function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);//关闭弹出层
                            parent.location.reload();//重新加载父页面表格
                        }, 1000);
                    }else{
                        layer.msg('操作失败');
                    }
                }
                ,error:function () {
                    console.log("ajax error");
                }
            });
            return false;
        });
    });
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var endDate= laydate.render({
            elem: '#end_time',//选择器结束时间
            type: 'datetime',
            trigger:'click',
            min:"1970-1-1",//设置min默认最小值
            done: function(value,date){
                startDate.config.max={
                    year:date.year,
                    month:date.month-1,//关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                }
            }
        });

        //日期范围
        var startDate=laydate.render({
            elem: '#start_time',
            type: 'datetime',
            trigger:'click',
            max:"2099-12-31",//设置一个默认最大值
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1, //关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });
    });
</script>
</body>
</html>